import java.text.DateFormat;
import java.util.Date;

public class CitationBuilderException extends Exception {

	private static final long serialVersionUID = 1L;
	String message = "";
	DateFormat df = DateFormat.getTimeInstance(DateFormat.FULL);
	String messageTitle = "";
	
	public static final String DBMappingErr = "Receiving Error When Trying to Mapping Fields With Database.";
	public static final String DBMappingReadErr = "Receiving Error When Trying to Accessing Mapping File.";
	public static final String ReadingConfFileErr = "Receiving Error When Reading Configuration File.";
	public static final String ReadingOutPutFileErr = "Receiving Error When Reading Output File.";
	public static final String OutPutFileNotFoundErr = "Receiving Error When Output File Not Found.";
	public static final String CitationModuleErr = "Receiving Error When using Citation Module.";
	public static final String WritingResultErr = "Receiving Error When writing result out.";
	public static final String DBCleaningErr = "Receiving Error When Trying to Clean Database Resource.";
	public static final String DBSendingSQLErr = "Receiving Error When Trying to Sending SQL Statement.";
	public static final String DBGetResultSetErr = "Receiving Error When Trying to Get Database Resultset.";
	public static final String JDBCClassNotFoundErr = "JDBC Driver not Set Properly.";
	public static final String DBConnectionErr = "Receiving Error When Trying to Connect to Database Resource.";
	public static final String UnableToCreateOutputFileErr = "eceiving Error When Trying to Create Output File.";
	public static final String CreateTempFileErr = "Receiving Error When Trying to Create Temporary File.";
	public static final String UsingXMLProcessErr = "Receiving Error When Trying to Use XML Processor.";
	public static final String PrintResultErr = "Receiving Error When Trying to Print the Result.";
	
	public CitationBuilderException() {
		this.setMessageTitle();
	}
	
	public String sendError() {
		return this.message;
	}
	
	public void setMessage(String msg) {
		this.message = msg;
	}
	
	private void setMessageTitle() {
		this.messageTitle = "[" + this.df.format(new Date()) + "] Error found: ";		
	}
	
	public String sendMessage() {
		return this.messageTitle + this.message;
	}
	
	public String sendMessageHTML() {		
		String labelLeft = "<h3>";		
		String labelRight = "</h3>";
		return labelLeft + this.messageTitle + labelRight + this.message;		
	}
	
	public static void printStrings(String input[]) {
		System.out.println("Array {");
		for (int i = 0; i < input.length; i++) {
			System.out.println("index " +  i + " = " + input[i]);
		}
		System.out.println("}");
	}
	
}